<?php
defined('_JEXEC') or die;

class BakerysControllerCart extends JControllerAdmin
{

	public function getModel($name = 'Cart', $prefix = 'BakerysModel', $config = array('ignore_request' => true))
	{
		$model = parent::getModel($name, $prefix, $config);
		return $model;
	}

	public function checkout()
	{				
		$input = JFactory::getApplication()->input;
		$location_id = $input->get("location");
		$location_alias = $input->get("location_alias");
		
		$model = $this->getModel();	
		$model->storeCart();
		if (JFactory::getUser()->id == 0)
		{					
			$this->setRedirect(JRoute::_("index.php?option=com_bakerys&view=regisuser&location=$location_id:$location_alias"));
		}
		else 
			$this->setRedirect(JRoute::_("index.php?option=com_bakerys&view=billaddress&location=$location_id:$location_alias"));
			
	}

	public function checkoutguest()
	{
		$this->setRedirect("index.php?option=com_bakerys&view=billaddress&" .$email);
	}
}
